package com.sita.bluetactivity.TripFragment;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.ImageView;
import android.widget.TabHost;
import android.widget.TextView;

import com.sita.bluetactivity.R;

/**
 * Created by Jason on 2016/9/21.
 */
public class VehicleTripFragment extends Fragment {
    private TabHost driveStatTab;
    private View  dayData, historyData;
    private static boolean setMyTab;
    private ImageView back;
    private TextView head;
    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return inflater.inflate(R.layout.fragment_trip,null);
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        dayData = LayoutInflater.from(getActivity()).inflate(R.layout.tab_day_data, null);
        historyData = LayoutInflater.from(getActivity()).inflate(R.layout.tab_history_data, null);
        driveStatTab = (TabHost)getActivity().findViewById(R.id.drive_stat_tab_host);
        driveStatTab.setup();
        setTab();
    }


    private void setTab() {
        TabHost.TabSpec tab_day_data = driveStatTab.newTabSpec("daydata");
        tab_day_data.setContent(R.id.fragment_day_data);
        tab_day_data.setIndicator(dayData);
        driveStatTab.addTab(tab_day_data);

        TabHost.TabSpec tab_history_data = driveStatTab.newTabSpec("historydata");
        tab_history_data.setContent(R.id.fragment_history_data);
        tab_history_data.setIndicator(historyData);
        driveStatTab.addTab(tab_history_data);
        driveStatTab.setCurrentTab(1);
        FragmentManager manager =getChildFragmentManager();
        FragmentTransaction transaction = manager.beginTransaction();
        transaction.replace(R.id.fragment_day_data, new DayDataFragment());
        transaction.replace(R.id.fragment_history_data, new HistoryDataFragment());
        transaction.commit();
    }
}
